﻿using System.Text.RegularExpressions;

namespace YourLastOptionsDialog.Common
{
    /// <summary>
    /// A simple helper class that offers some string formatting features.
    /// </summary>
    public static class StringFormatter
    {
        /// <summary>
        /// Creates a nicer display name from a camel case source string.
        /// </summary>
        /// <param name="source">The source string in camel case notion.</param>
        /// <returns>A string that contains the formatted source string.</returns>
        public static string DisplayNameFromCamelCase(string source)
        {
            // not perfect for all cases, but a quick way for the lazy ones 
            // that e.g. don't provide attributes with display names explicitly :)
            var result = Regex.Replace(source, "([A-Z]+|[0-9]+)", " $1", RegexOptions.Compiled).Trim();
            return result;
        }
    }
}